//
//  ControllerManager.m
//  SoutheastAsia
//
//  Created by rimi on 16/1/18.
//  Copyright © 2016年 zlj. All rights reserved.
//

#import "ControllerManager.h"
#import "LeftDrawerViewController.h"
#import "SceneryViewController.h"

@interface ControllerManager ()

@property (nonatomic, strong) ZLJDrawerViewController * drawerVC;
@property (nonatomic, strong) UIViewController * rootViewContorller;

@end

@implementation ControllerManager

+ (instancetype)sharedManager {
    static ControllerManager *manager;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[ControllerManager alloc] init];
    });
    return manager;
}
#pragma mark - callback / action

- (void)gestureOfOpenDrawer:(UIScreenEdgePanGestureRecognizer *)gesture {
    [self.drawerVC openLeftDrawer];
}
- (void)backMainViewGestureTaped:(UITapGestureRecognizer *)gesture {
    [self.drawerVC closeLeftDrawer];
}

- (void)leftDrawerOpen:(UIButton *)sender
{
    if (self.drawerVC.drawerViewIsOpen == NO) {
        [self.drawerVC openLeftDrawer];
    }else{
        [self.drawerVC closeLeftDrawer];
    }
}

#pragma mark - getter
- (UIViewController *)rootViewContorller {
    if (!_rootViewContorller) {
        UINavigationController * navc = [[UINavigationController alloc] initWithRootViewController:self.drawerVC];
        navc.navigationBarHidden = YES;
        _rootViewContorller = navc;
    }
    return _rootViewContorller;
}

- (ZLJDrawerViewController *)drawerVC {
    if (!_drawerVC) {
        LeftDrawerViewController *left = [[LeftDrawerViewController alloc] init];
        SceneryViewController *scenery = [[SceneryViewController alloc] init];
        UINavigationController *mainNC = [[UINavigationController alloc] initWithRootViewController:scenery];
        mainNC.navigationBarHidden = YES;
        _drawerVC = [[ZLJDrawerViewController alloc] initWithMainViewController:mainNC leftViewController:left];
    }
    return _drawerVC;
}



@end
